home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver17.zip / VoodooLights / Sources / main.c < prev    next >
C/C++ Source or Header  |  1997-07-24  |  2KB  |  108 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <time.h>
  11. #include <math.h>
  12. #include <glide.h>
  13. #include <windows.h>
  14.  
  15. #include "defines.h"
  16. #include "mat.h"
  17. #include "win.h"
  18. #include "hw.h"
  19. #include "rgb.h"
  20. #include "cam.h"
  21. #include "tex.h"
  22. #include "cell.h"
  23.  
  24. Float dt ;
  25.  
  26. Float Time = 0.0 ;
  27. static Float absTime ;
  28.  
  29. static XYZ from, at, up ;
  30. static Float  FP, BP, focus ;
  31. static Bool all_created = False ;
  32.  
  33. char tex_path[ 512 ] ;
  34.  
  35. static void main_InitCamera()
  36. {
  37.  
  38.     from.x = 0.0 ;
  39.     from.y = 0.0 ;
  40.     from.z = -100.0 ;
  41.  
  42.     at.x = 0.0f ; at.y = 0.0f ; at.z = 0.0f ;
  43.     up.x = 0.0f ; up.y = 1.0f ; up.z = 0.0f ;
  44.  
  45.     focus = 0.6 ;
  46.  
  47.     FP = 5.0 ;
  48.     BP = 4000.0 ;
  49.  
  50.     cam_SetCamParameters( & from, & at, & up, focus, FP, BP ) ;
  51.     cam_BuildCameraTransform() ;
  52. }
  53.  
  54. void main_InitModule( void )
  55. {
  56.     time_t timer ;
  57.     int ret ;
  58.  
  59.     if( ! GetEnvironmentVariable("VoodooLights_Texture_Path", tex_path, sizeof( tex_path ) ) )
  60.         sprintf( tex_path, "./Textures") ;
  61.     
  62.     srand( time( & timer ) % RAND_MAX ) ;
  63.     
  64.     if( ! hw_InitHardware() ) {
  65.         
  66.         hw_ShutdownHardware() ;
  67.  
  68.         win_MessageBox( 1, "Glide Init Error", "Trouble with 3DFX Graphics hardware." ) ;
  69.     }
  70.  
  71.     rgb_InitPalette() ;
  72.     main_InitCamera() ;
  73.  
  74.     
  75.     absTime = 0.001 * GetCurrentTime() ;
  76.  
  77.     main_InitCamera() ;
  78.     cell_InitModule() ;    
  79.  
  80.     grGlideShamelessPlug( Time < 10.0 ) ;
  81.  
  82. }    
  83.  
  84. void main_MainLoop( void )
  85. {    
  86.     Cell **p ;
  87.  
  88.  
  89.     dt = 0.001 *  GetCurrentTime() - absTime ;
  90.     
  91.     absTime += dt ;
  92.     Time += dt ;
  93.  
  94.     if( cam_NewCamera() ) cam_BuildCameraTransform() ;
  95.  
  96.     grGlideShamelessPlug( Time < 10.0 && hw_VoodooChipset() ) ;
  97.  
  98.     grBufferSwap( 3 ) ;
  99.     grColorMask( FXTRUE, FXFALSE ) ;
  100.     grBufferClear( 0x0, 0, 0 );
  101.  
  102.     cell_MainLoop() ;
  103.  
  104.  
  105.  
  106.     while( grBufferNumPending() > 2 ) ;
  107. }
  108.